﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Web.Services;
using System.IO;

public partial class Admin_Slider : System.Web.UI.Page
{
    SliderController sliderController = new SliderController();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

            grvSlider.DataSource = sliderController.GetAll();
            grvSlider.DataBind();
            if (grvSlider.Rows.Count > 0)
            {
                grvSlider.UseAccessibleHeader = true;
                grvSlider.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
        }
    }
    [WebMethod]
    public static string deleteSlider(int slider_id,string path)
    {
        SliderController sliderController = new SliderController();
        if(sliderController.Delete(slider_id)>0)
        {
            string fileUpload = HttpContext.Current.Server.MapPath("~/");
            string file = fileUpload + path;
            if(File.Exists(file))
            {
                File.Delete(file);
            }
            return "true";
        }
        else
        {
            return "false";
        }
    }
}